package main

import (
        "flag"
        "net/http"
        "strings"
)

var(
    dir = flag.String("dir", ".", "files directory to serve")
)

func main() {
        fs := http.FileServer(http.Dir(*dir))
        //log.Print("Serving " + dir + " on http://localhost:8087")
        http.ListenAndServe(":8087", http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
                resp.Header().Add("Cache-Control", "no-cache")
                if strings.HasSuffix(req.URL.Path, ".wasm") {
                        resp.Header().Set("content-type", "application/wasm")
                }
                fs.ServeHTTP(resp, req)
        }))
}
